$(function(){

    /*grafickySelect*/
    if($('.grafickySelect').length!=0)
    {
        var selectClass = 'bg-mapa bg-select pointer';
        var selectHeight = '24px';

        var open;

        $('.grafickySelect').each(function(){

          var formSelect = $(this);

          /*vytvoreni grafickeho selectu*/
          var select = $('<div />');
          select.addClass(selectClass);

          /*aktualni text*/
          var selectedText = formSelect.find('option:selected').text();
          if(selectedText!='') select.text(selectedText);
          else select.text(formSelect.find('option:eq(0)').text());

          /*pridani do rodicoveho elementu*/
          formSelect.parent().append(select);

          /*možnosti*/
          var options = $('<div />');
          options.attr('class','options').hide();

          $(this).find('option').each(function(){

            var formOption = $(this);
            var option = $('<div />');
            if(formOption.attr('selected')=='selected') option.addClass('href2');
            else option.addClass('href1');

            option.text(formOption.text()).attr('data-val',formOption.val()).addClass('pointer option');
            options.append(option);

            option.click(function(event){
                event.stopPropagation();
                options.find('.option').removeClass('href2').addClass('href1');
                option.removeClass('href2').addClass('href2');
                options.hide();
                select.text(option.text());
                formSelect.val(option.attr('data-val')).change();
            })
          })

          formSelect.parent().append(options);

          /*schovani form selectu*/
          formSelect.hide();

          /*click*/
          select.click(function(event){
              event.stopPropagation();
              options.toggle();
          })
        });

    }
    /*grafickySelect*/
    
});